<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <%@ include file="/sysoutUtil/inc.jsp" %>
    <title>企业列表</title>
</head>
<body>
<table class="table" id="emp-table" border="1"></table>
<div id="updateOrgDialog"></div>
<script>
    $.ajax({
        url:'http://localhost:8071/AuthOrgInfo/SelectAuthOrgInfo',
        type:'get',
        dataType:'json',
        success:function(data){
            var examStatus = 2;
            var examStatus2 = 3;
            var Status = "";
            if(data.examStatus==1){
                Status="请求认证"
            }else if(data.examStatus==2){
                Status="认证通过"
            }else{
                Status="认证失败"
            }
            var str = '<tr>\n' +
                '<td>主键</td>\n' +
                '<td>组织团体名称</td>\n' +
                '<td>组织团体类型</td>\n' +
                '<td>认证状态</td>\n' +
                '<td>详细信息</td>\n' +
                '<td>证件到期时间</td>\n' +
                '<td>详细地址</td>\n' +
                '<td>操作</td>\n' +
                '</td>\n' +
                '</tr>'
            for ( var i = 0; i < data.length; i++) {
                str +=

                    '<tr>\n' +
                    '<td>'+data[i].orgId+'</td>\n' +
                    '<td>'+data[i].orgName+'</td>\n' +
                    '<td>'+data[i].orgType+'</td>\n' +
                    '<td>'+Status+'</td>\n' +
                    '<td>'+data[i].orgInfo+'</td>\n' +
                    '<td>'+data[i].orgTermTime+'</td>\n' +
                    '<td>'+data[i].orgPlce+'</td>\n' +
                   "<td><input type='button'value='认证通过'onclick='updateYes("+data[i].orgId+","+examStatus+","+data[i].userId+")'> <input type='button'value='认证驳回'onclick='updateNo("+data[i].orgId+","+examStatus2+","+data[i].userId+")'> </td>\n"+
                    '</td>\n'+
                    '</tr>'
            }
            $("#emp-table").html(str)

        }
    })

    function updateNo(orgId,examStatus2,userid){
        alert(orgId+"---"+examStatus2+"-----"+userid)
        $.ajax({
            url:'http://localhost:8071/AuthOrgInfo/UpdateAuthOrgInfo',
            data:{
                "orgId":orgId,
                "examStatus":examStatus2,
                "userid":userid
            },
            type:'put',
            dataType:'json',
            success:function(data){
                if(data==1){
                    alert("成功")
                }else{
                    alert("失败")
                }

            }
        })
    }
    function updateYes(orgId,examStatus,userid){
        alert(orgId+"---"+examStatus+"-----"+userid)
        $.ajax({
            url:'http://localhost:8071/AuthOrgInfo/UpdateAuthOrgInfo',
            data:{
                "orgId":orgId,
                "examStatus":examStatus,
                "userid":userid
            },
            type:'put',
            dataType:'json',
            success:function(data){
                if(data==1){
                    alert("成功")
                }else{
                    alert("失败")
                }

            }
    })
    }

</script>

</body>
</html>
